<!--
 * @Author: xjt
 * @Date: 2021-06-24 23:05:13
 * @LastEditTime: 2021-06-29 16:04:39
 * @Description: 全市集中隔离人员中有犯罪前科和违法记录人员
 * @LastEditors: cqg
-->
<template>
	<basic-container v-loading="loading" element-loading-text="数据加载中...">
		<el-date-picker value-format="yyyy-MM-dd HH:mm:ss" v-model="useStartTime" type="datetime" placeholder="选择日期时间">
		</el-date-picker>
		<el-button @click="search()" type="primary">搜索</el-button>
		<el-button @click="download()" type="primary">导出</el-button>
		<el-table :data="tableData" style="width: 100%">
			<el-table-column prop="statisticTime" label="序号" width="50">
				<template slot-scope="scope">
				            {{scope.$index+1}}
				        </template>
			</el-table-column>
			<el-table-column prop="substation" label="属地分局" width="150">
			</el-table-column>
			<el-table-column prop="policeStation" label="属地派出所" width="150">
			</el-table-column>
			<el-table-column label="有犯罪前科或违法行为">
				<el-table-column prop="personName" label="姓名" width="90">
				</el-table-column>
				<el-table-column prop="personIdCard" label="证件号码" width="160">
				</el-table-column>
			</el-table-column>
			<el-table-column prop="situationDescribe" label="犯罪前科或违法记录情况描述" width="180">
			</el-table-column>
			<el-table-column prop="hotelName" label="入住酒店名称" width="100">
			</el-table-column>
			<el-table-column prop="checkInTime" label="入住时间" width="110">
			</el-table-column>
			<el-table-column prop="controlMeasures" label="管控措施" width="120">
			</el-table-column>
			<el-table-column prop="isControlled" label="是否可控" width="100">
			</el-table-column>
			<el-table-column prop="leader" label="责任所领导" width="100">
			</el-table-column>
			<el-table-column prop="policeman" label="责任民警" width="100">
			</el-table-column>
			<el-table-column prop="remark" label="备注" width="130">
			</el-table-column>
		</el-table>
		<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
		 :page-sizes="[5, 10, 30, 50]" :page-size="pagesize" layout="total, prev, pager, next,sizes" :total="total">
		</el-pagination>
	</basic-container>
</template>

<script>
	import {
		queryAll,
		exportAll,
		querySearch
	} from "@/views/yq-totalSearch/api/lawbreak.js";
	export default {
		data() {
			return {
				// 页面loading
				loading: false,
				tableData: [],
				currentPage: 1, //初始页
				pagesize: 5, //    每页的数据
				total: 0,
				useStartTime:'',//输入时间
			}
		},
		created() {
			this.handleUserList()
		},
		methods: {
			download() {
				this.publicExport(
					'xzczxdddc',
					'/personUnlawfulAct/export/info', {},
					'xls',
					'get'
				);
			},
			search() {
				let useStartTime = this.useStartTime;
				// let jsonObj = JSON.parse(useStartTime);
				// console.log(jsonObj)
				let date = new Date();
				
				let year = date.getFullYear(); //年 ,从 Date 对象以四位数字返回年份
				let month = date.getMonth() + 1; //月 ,从 Date 对象返回月份 (0 ~ 11) ,date.getMonth()比实际月份少 1 个月
				let day = date.getDate(); //日 ,从 Date 对象返回一个月中的某一天 (1 ~ 31)
				
				let hours = date.getHours(); //小时 ,返回 Date 对象的小时 (0 ~ 23)
				let minutes = date.getMinutes(); //分钟 ,返回 Date 对象的分钟 (0 ~ 59)
				let seconds = date.getSeconds(); //秒 ,返回 Date 对象的秒数 (0 ~ 59)   
				
				//获取当前系统时间  
				let currentDate = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
				if (useStartTime > currentDate) {
					this.$message.error("时间不能超过当前时间")
				}else if (useStartTime.length == 0) {
					this.$message.error("请输入搜索时间")
				} else {
					// debugger
					let params = {useStartTime:this.useStartTime};
					// console.log(params)
					querySearch(params)
						.then(res => {
							// debugger
							console.log(res)
							this.tableData = res.data.data.records;
						})
						.finally(() => {
							this.loading = false;
						});
				}
			},
			// 初始页currentPage、初始每页数据数pagesize和数据data
			handleSizeChange: function(size) {
				this.pagesize = size;
				// console.log(this.pagesize) //每页下拉显示数据
				this.handleUserList()
			},
			handleCurrentChange: function(currentPage) {
				this.currentPage = currentPage;
				// console.log(this.currentPage) //点击第几页
				this.handleUserList()
			},
			handleUserList() { //这里调接口方法
			 this.loading = true;
				let params = {size:this.pagesize,current:this.currentPage}
				queryAll(params)
				
					.then(res => {
						// const { current, size, total, records } = res.data.data;
						// console.log(res + '--------')
						this.tableData = res.data.data.records;
						this.total = res.data.data.total;
						// console.log(this.total)
						// console.log(this.tableData)
					})
					.finally(() => {
						this.loading = false;
					});
			}
		},
		
	}
</script>

<style lang="scss" scoped>
	.el-input {
		width: 30%;
		padding: 20px;
	}
	.el-pagination {
	    float: right;
	}
</style>
